package com.changgou.system.business.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@Component
public class AdListener {


/** 接受广告队列中的数据进行处理,
//  业务是, 模式http请求到nginx, 让nginx调用lua脚本进行大广告redis中的数据更新
// * @param position
*/
//1 rabbirmq  接受广告信息改变
    @Autowired
    private RestTemplate restTemplate;
@RabbitListener(queues = "ad_update_queue")
public void receiveMessage(String position){
    System.out.println("接收到消息:"+position);
   String url="http://192.168.200.128/ad_update?position="+position;
    ResponseEntity<Map> forEntity = restTemplate.getForEntity(url, Map.class);
    Map body = forEntity.getBody();
    System.out.println(body);
}

}
